
<!DOCTYPE html>
<html>

<head>
   
    
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--360浏览器优先以webkit内核解析-->


<title>日常费用报销申请</title>

<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
<link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
 <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
<!-- Sweet Alert -->
<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
     <link rel="stylesheet" href="__STATIC__/layout/css/channel.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <style>

    </style>

</head>

<body class="white-bg" style="padding: 3px;font-size: 12px">
    <div class="page-heade">
       <h2 class="title_color text-center">日常费用报销申请</h2>
    </div>
    <form action="" class="form-inline" id="form1">
    <input type="hidden" name="aid" value="{$aid}" id="aid"/>
    <input type="hidden" name="state" value="1" id="state"/>
        <table class="table table-bordered bud_hei text-center">
            <tr>
                <td colspan="4" class="text-left">
                    <p>温馨提示：请在发票粘贴联上注明此申请单编号： <a href="javascript:;">点击查看图例</a></p><br>
                    <p>并邮寄至： <span class="font-bold">广东省广州市番禺大道北383号6栋801 曾小姐收，020-85518159，赵六，13600000000签收。</span>(如邮寄地址未显示，请联系相关人员进行邮寄地址添加。)</p>
                </td>
            </tr>
            <tr>
                <td>代办人(申请人)：</td>
                <td class="text-left">{$cuser.em_name}</td>
                <td>报销单创建日期：</td>
                <td id="applytime" class="text-left">{$ctime} </td>
            </tr>
            <tr>
                <td>费用计入部门 <span class="colorRed">*</span></td>
                <td class="text-left">
                      <div class="container-fluid">
                        <div class="row">
                            <div class="col-xs-8">
                                <div class="input-group" {if $aid} style="display:none;" {/if}>
                                    <input type="text" placeholder="请输入关键字或空格查询" class="form-control jrbm" name="jrbm" {if $aid} value="{$apply.jrbm}" {/if}>
                                    <div class="input-group-btn">
                                        <button type="button" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                        </ul>
                                    </div>
                                </div>
                                <div class="selectedOnlyOne " {if $aid} {else/} style="display:none;" {/if} >
                                    <span class="inin">{if $aid}{$jrbm}{/if}</span>
                                    <span class="close">×</span>
                                </div>
                            </div>
                            <div class="col-xs-4">
                                <button class="btn btn-primary select_jrbm" type="button" >选择</button>
                            </div>
                        </div>
                    </div>
                </td>
                 <td>报销人 <span class="colorRed">*</span></td>
                <td class="text-left">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-xs-8">
                                    <div class="input-group" {if $aid} style="display:none;" {/if}  >
                                        <input type="text" placeholder="请输入关键字或空格查询" class="cname form-control"  name="baoxiaoren" {if $aid} value="{$apply.baoxiaoren}" {/if}>
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="selectedOnlyOne " {if $aid} {else/} style="display:none;" {/if} >
                                      
                                        <span class="inin">{if $aid}{$baoxiaoren}{/if}</span>
                                        <span class="close">×</span>
                                    </div>
                                </div>
                               <div class="col-xs-4">
                                <button class="btn btn-primary select_cname" type="button" >选择</button>
                            </div>
                           </div>
                        </div>
                </td>
            </tr>
            <tr>
                <td>报销单主题 <span class="colorRed">*</span></td>
                <td class="text-left">
                    <input type="text" name="title" {if $aid} value="{$apply.title}" {/if} class="form-control">
                </td>
                <td>报销归入考核期 <span class="colorRed">*</span></td>
                <td>
                <select class="form-control select" name="kaohe" id="kaohese">
                    {if $aid}
                         {volist name="kaohe" id="k"}
                            {if $k.id==$apply.kaohe}
                            <option value="{$k.id}" selected>{$k.nian}-{$k.yue}</option>
                            {else/}
                            <option value="{$k.id}">{$k.nian}-{$k.yue}</option>
                            {/if}
                        {/volist}
                        
                    {else/}
                        {volist name="kaohe" id="k"}
                            <option value="{$k.id}">{$k.nian}-{$k.yue}</option>
                        {/volist}
                    {/if}
                </select>
                </td>
            </tr>
            <tr>
                
                <td>支付方式 <span class="colorRed">*</span></td>
                <td class="text-left" colspan="3">
                    <select class="form-control select" id="payway" name="payway">
                        <option value="0">请选择</option>
                        {if $aid}
                            {volist name="pay" id="p"}
                                {if $p.id==$apply.payway}
                                <option value="{$p.id}" selected>{$p.title}</option>
                                {else/}
                                <option value="{$p.id}">{$p.title}</option>
                                {/if}
                            {/volist}
                        {else/}
                            {volist name="pay" id="p"}
                                <option value="{$p.id}">{$p.title}</option>
                            {/volist}
                        {/if}
                    </select>
                </td>
            </tr>
            <tr>
                <td>三级费用科目 <span class="colorRed">*</span></td>
                <td class="text-left" colspan="3">
                    <div class="col-xs-4">
                        <div class="input-group" id="" >
                            <input type="text"   placeholder="请输入关键字或空格查询" class="form-control inputremindPeple" id="fei"  value="">
                            <input type="hidden" name="feis" id="feis"/>
                            <div class="input-group-btn">
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-2">
                        <button class="btn btn-primary btn-sm" type="button" id="select_fei">选择</button>
                        <input type="button" class="btn btn-primary btn-sm" id="clear_fei" value="清空"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td>您选定的三级费用科目是</td>
                <td colspan="3" id="threeproject" class="text-left">
                    <div class="duoxuan" id="selected_fei">
                        {if $aid}
                            {volist name="feiyong" id="f"}
                                <span class="ren feilist" data-id="{$f.id}">{$f.title}<span class="close">×</span></span>
                            {/volist}
                        {/if}
                    </div>
                </td>
            </tr>
            <tr>
                <td>报销事由<span class="colorRed">*</span></td>
                <td colspan="3" class="text-left">
                    <textarea class="form-control" style="resize: none;width: 60%;height: 50px" id="bxcause" name="reason">{if $aid}{$apply.reason}{/if}</textarea>
                </td>
            </tr>
            <tr class="text-left">
                <td class="text-center">出差申请单号</td>
                <td colspan="3">
                    {if $chuchai}
                        <div class="row">
                            {volist name="chuchai" id="c"}
                                <div class="col-xs-4">
                                    <input type="checkbox" name="chuchai[]"  value="{$c.id}" {if $c.ischeck==1} checked {/if} />
                                    <a class="J_menuItem detail" title="{$c.no}" href="{:url('Chuchai/detail')}?aid={$c.id}">{$c.no}({$c.title})</a>
                                </div>
                            {/volist}
                        </div>
                    {else/}
                    <b>近三个月无出差申请</b>
                    {/if}
                </td>
            </tr>
            
            <tr>
              <td>万用申请单</td> 
              <td colspan="3" class="text-left">
                    {if $wanneng}
                        <div class="row">
                            {volist name="wanneng" id="c"}
                                <div class="col-xs-4">
                                    <input type="checkbox" name="wanneng[]" value="{$c.id}" {if $c.ischeck==1} checked {/if}/>
                                    <a class="J_menuItem detail" title="{$c.no}" href="{:url('Wanyongapply/detail')}?aid={$c.id}">{$c.no}({$c.title})</a>
                                </div>
                            {/volist}
                        </div>
                    {else/}
                    <b>近三个月无万能申请</b>
                    {/if}
              </td> 
            </tr>
             <tr>
             <td>作废原因 <span class="colorRed">（如选择作废则必须填写）</span></td>
                <td colspan="3" class="text-left"><textarea name="feireason" class="form-control" style="width: 70%;resize: none;"></textarea></td>
            </tr>
        </table>
        <table class="table-bordered table bud_hei">
            <tr>
                <td colspan="8"><a href="javascript:;" class="btn-sm btn btn-success" id="addcostbx">添加费用报销明细</a><span class="lr_5"></span><span>(至少添加一条费用报销明细)</span></td>
            </tr>
            <tr class="info text-center">
                <td>操作</td>
                <td>序号</td>
                
                <td>起止时间</td>
                <td>出发地点</td>
                <td>到达地点</td>
                {if $aid}
                    {volist name="feiyong" id="f"}
                        <td>{$f.title}</td>
                    {/volist}
                {/if}
                <td>费用说明</td>
                <td>费用计入经销商</td>
                <td>预算情况</td>
            </tr>
            {if $aid}
                {volist name="detail" id="d" key="k"}
                    <tr class="text-center mxs">
                        <td><button class="btn btn-danger shanchu" type="button" did="{$d.id}">删除</button></td>
                        <td>{$k}</td>
                        
                        <td>{$d.start}<br/>{$d.end}</td>
                        <td>{$d.chufa}</td>
                        <td>{$d.mudi}</td>
                        {if $aid}
                            {volist name="feiyong" id="f"}
                                <td>
                                    
                                        {if $d.feiid==$f.id}
                                            {$d.feis}
                                        {/if}
                                    
                                </td>
                            {/volist}
                        {/if}
                        <td>{$d.remark}</td>
                        <td>{$d.jxs}</td>
                        <td class="ysdeng" did="{$d.id}">
                            {if $d.yid}
                                {if $d.ytype==1}
                                    <button class="btn btn-primary" type="button">绿灯</button>
                                {elseif $d.ytype==2}
                                    <button class="btn btn-warning" type="button">黄灯</button>
                                {else/}
                                    <button class="btn btn-danger" type="button">红灯</button>
                                {/if}
                            {else/}
                                <button class="btn btn-danger" type="button">未设定预算</button>
                            {/if}
                        </td>
                    </tr>
                {/volist}
            {/if}
        </table>
         <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
            {volist name="logs" id="l"}
          <tr>
              <td>{$l.USERNAME} 审批动作：{$l.MEMO}；审批意见：{if $l.COMMENTS}{$l.COMMENTS}{else/}无{/if}(审批时间：{$l.ACTIONTIME})</td>
          </tr>
          
          {/volist}
      </table>
       <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-sm btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" {if $aid}{if $apply.fujian} value="{$apply.fujian}" {/if}{/if}  >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>

       <div class="padding-10 text-center">
          <input type="hidden" id="nodeKey" name="nodeKey"/>
          <input type="hidden" id="selectId" name="selectId"/>
          <input type="hidden" id="selectName" name="selectName"/>
            {volist name="btn.nextNodes" id="b"}
              {if $b.nodeName=='结束'}
              <input type="button" class="btn-danger btn" onclick="zuofei('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="点此作废"/>
              {else/}
              <input type="button" class="btn-info btn" onclick="baocun('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="保存并提交工作流"/>
              {/if}
            {/volist}
        </div>
    </form>
  
    
<!-- 全局js -->
<script src="__STATIC__/layout/js/jquery.min.js"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Sweet alert -->
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>

<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
var fr={$from};
function baocun(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('baocunchuli')}",
          data:$('#form1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  if(fr==1)
                                        location.href="{:url('manage')}"
                                  else
                                        location.href="{:url('Workflowdb/index')}"
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
}
function zuofei(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('zuofeichuli')}",
          data:$('#form1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('manage')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
}
function yusuantongbu(){
    if($("#aid").val()!=""){
        if($("[name='jrbm']").val()!=""){
            $.post("{:url('yusuantongbu')}",{jrbm:$("[name='jrbm']").val(),aid:$("#aid").val(),kaohe:$("#kaohese").val()},function(re){
                if(re!=""){
                    var data=JSON.parse(re);
                    $(".ysdeng").each(function(){
                        for(var i=0;i<data.length;i++){
                            if(data[i]["id"]==$(this).attr("did")){
                                if(data[i]["ytype"]==0){
                                    $(this).html('<button class="btn btn-danger" type="button">未设定预算</button>')
                                }else if(data[i]["ytype"]==1){
                                    $(this).html('<button class="btn btn-primary" type="button">绿灯</button>')
                                }else if(data[i]["ytype"]==2){
                                    $(this).html('<button class="btn btn-warning" type="button">黄灯</button>')
                                }else{
                                    $(this).html('<button class="btn btn-danger" type="button">红灯</button>')
                                }

                                break;
                            }
                        }
                    })
                }
            })
        }else{
            $(".ysdeng").html('<button class="btn btn-danger" type="button">未选择部门</button>')
        }
    }
}
$("#kaohese").change(function(){
   yusuantongbu();
})

$(".shanchu").click(function(){
     

    var t=$(this);
     var num=0;
    $(".mxs").each(function(){
        num++;
    })
    if(num>1){
        swal({
            title: "提示",
            text: "您真的要删除么？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#FF3333",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: true
            },function(isConfirm){
                if(isConfirm){
                     $.post("{:url('shanchumx')}",{id:t.attr("did")},function(re){
                        if(re==1){
                            swal({
                                title: "完成",
                                text:  "操作已成功",
                                type: "success"
                                },function(){
                                    t.parent().parent().remove();
                                });
                        }else{
                              swal({
                                title: "错误",
                                text:  "系统繁忙请稍后再试",
                                type: "warning"
                                });
                        }
                    })
                }
        })
       
    }else{
        swal({
                    title: "错误",
                    text:  "至少保留一条明细",
                    type: "warning"
                    });
    }
})

$("#addcostbx").click(function(){
    var fei=[];
    $(".feilist").each(function(){
        fei.push($(this).attr("data-id"));
    })
    $("#feis").val(fei.join(',')); 
    $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('addmain')}",
          data:$('#form1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
             var re=JSON.parse(data);
             if(re["state"]==2){
                swal({
                    title: "错误",
                    text:  re["msg"],
                    type: "warning"
                    });
            }else{
                $("#aid").val(re["msg"]);
                layer.open({
                    type: 2,
                    title: '添加日常费用报销明细',
                     area: ['90%', '90%'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: "{:url('zuofeidetail')}?aid="+$("#aid").val()+"&feis="+$("#feis").val()+"&from="+fr
                });
            }
          }
        });
})
 $('#select_fei').on('click',function () {
                var index = layer.getFrameIndex(window.name)
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    maxmin:true,
                    content:'{:url("selectfei")}'
                })
                return  false
        })
 //产品单品搜索自动补全
    $("#fei").bsSuggest({
        url: "{:url('feiyongkemu3json')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).val('')
        var bool = false
        $('#selected_fei .ren').each(function (idx,o) {
            if($(this).data('id') == keyword.id){
                bool = true;
            }
        })
        if(bool == false){
            $('#selected_fei').append('<span class="ren feilist" data-id="'+keyword.id+'">'+keyword.key+'<span class="close">×</span></span>');
            
        }
    });
//弹出选择我的支付人树
        $('body').on('click','.select_cname',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'支付人树',
                    maxmin:true,
                    content:'{:url("Apcaiwu/selectCname")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.feetype').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
    //支付人搜索自动补全
    $(".cname").bsSuggest({
        url: "{:url('Apcaiwu/cnamejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
      //弹出选择我的费用计入部门树
        $('body').on('click','.select_jrbm',function () {
            var _this = this
                layer.open({
                    type:2,
                    area:['60%','60%'],
                    title:'费用计入部门树',
                    maxmin:true,
                    content:'{:url("Ti_apply/selectJrbm")}',
                    btn:'确定',
                    btnAlign:'c',
                    yes:function (i,o) {

                        var id = $(o).find('iframe').contents().find('#renyuan').val()
                        var name = $(o).find('iframe').contents().find('#renyuanname').val()
                        if(id){
                            $(_this).closest('div').prev('div').find('.input-group').hide().find('.jrbm').val(id)
                            $(_this).closest('div').prev('div').find('.selectedOnlyOne').show().find('.inin').html(name)
                            yusuantongbu();
                        }
                        layer.close(i)
                    }
                })
                return  false
        })
     //费用计入部门搜索自动补全
    $(".jrbm").bsSuggest({
        url: "{:url('select/jrbmjson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)
         yusuantongbu();

    });
</script>
<script>
//关闭多选某一项
    $('body').on('click','.duoxuan .close',function () {
        $(this).closest('.ren').remove()
    })
 //清空
    $("#clear_fei").click(function(){
        $(".feilist").remove();
    })
   //取消单选
    $('body').on('click','.selectedOnlyOne .close',function () {
        $(this).closest('.selectedOnlyOne').hide().find('.inin').html('')
        $(this).closest('.selectedOnlyOne').prev('.input-group').show().find('input').val('')
        if($("[name=jrbm]").val()==""){
            yusuantongbu();
        }
    })
    $(function () {
        $('body').on('click','input[type=text]',function () {
            this.select()
        })
    })
</script>

<script>
    
  
  var jieshou = $("#area_id");
 sousuo(jieshou);
       function sousuo(id){
            id.bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: true, //以分隔符号分割的多关键字支持
            separator: ",", //多关键字支持时的分隔符，默认为空格
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: 'http://unionsug.baidu.com/su?p=3&t=' + (new Date()).getTime() + '&wd=',
            /*优先从url ajax 请求 json 帮助数据，注意最后一个参数为关键字请求参数*/
            jsonp: 'cb',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                var i, len, data = {
                    value: []
                };
                if (!json || !json.s || json.s.length === 0) {
                    return false;
                }

                // console.log(json);
                len = json.s.length;

                jsonStr = "{'value':[";
                for (i = 0; i < len; i++) {
                    data.value.push({
                        word: json.s[i]
                    });
                }
                data.defaults = 'baidu';

                //字符串转化为 js 对象
                return data;
            }
        });

          }

function back(){
    location.href="{:url('manage')}"
}
</script>

<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

         var ids = [{if $aid}{if $apply.fujian}value="{$apply.fujian}"{/if}{/if} ];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

        $('#renyuan').on('click','.ren .close',function () {
            $(this).closest('.ren').remove()
        })
    });
   

</script>

<script>
    $(".detail").click(menuItem);
    function menuItem() {
    // 获取标识数据
    var dataUrl = $(this).attr('href'),
        dataIndex = $(this).data('index'),
        menuName = $.trim($(this).attr("title")),
        flag = true;
    if (dataUrl == undefined || $.trim(dataUrl).length == 0)return false;

    // 选项卡菜单已存在
    top.$('.J_menuTab').each(function () {
        if ($(this).data('id') == dataUrl) {
            if (!$(this).hasClass('active')) {
                $(this).addClass('active').siblings('.J_menuTab').removeClass('active');
                scrollToTab(this);
                // 显示tab对应的内容区
                top.$('.J_mainContent .J_iframe').each(function () {
                    if (top.$(this).data('id') == dataUrl) {
                        top.$(this).show().siblings('.J_iframe').hide();
                        return false;
                    }
                });
            }
            flag = false;
            return false;
        }
    });

    // 选项卡菜单不存在
    if (flag) {
        var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
        top.$('.J_menuTab').removeClass('active');

        // 添加选项卡对应的iframe
        var str1 = '<iframe class="J_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
        top.$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(str1);

        //显示loading提示
//            var loading = layer.load();
//
//            $('.J_mainContent iframe:visible').load(function () {
//                //iframe加载完成后隐藏loading提示
//                layer.close(loading);
//            });
        // 添加选项卡
        top.$('.J_menuTabs .page-tabs-content').append(str);
        scrollToTab(top.$('.J_menuTab.active'));
    }
    return false;
}
//滚动到指定选项卡
function scrollToTab(element) {
    var marginLeftVal = calSumWidth(top.$(element).prevAll()), marginRightVal = calSumWidth(top.$(element).nextAll());
    // 可视区域非tab宽度
    var tabOuterWidth = calSumWidth(top.$(".content-tabs").children().not(".J_menuTabs"));
    //可视区域tab宽度
    var visibleWidth = top.$(".content-tabs").outerWidth(true) - tabOuterWidth;
    //实际滚动宽度
    var scrollVal = 0;
    if (top.$(".page-tabs-content").outerWidth() < visibleWidth) {
        scrollVal = 0;
    } else if (marginRightVal <= (visibleWidth - top.$(element).outerWidth(true) - top.$(element).next().outerWidth(true))) {
        if ((visibleWidth - top.$(element).next().outerWidth(true)) > marginRightVal) {
            scrollVal = marginLeftVal;
            var tabElement = element;
            while ((scrollVal - top.$(tabElement).outerWidth()) > (top.$(".page-tabs-content").outerWidth() - visibleWidth)) {
                scrollVal -= top.$(tabElement).prev().outerWidth();
                tabElement = top.$(tabElement).prev();
            }
        }
    } else if (marginLeftVal > (visibleWidth - top.$(element).outerWidth(true) - top.$(element).prev().outerWidth(true))) {
        scrollVal = marginLeftVal - top.$(element).prev().outerWidth(true);
    }
    top.$('.page-tabs-content').animate({
        marginLeft: 0 - scrollVal + 'px'
    }, "fast");
}
//计算元素集合的总宽度
function calSumWidth(elements) {
    var width = 0;
    top.$(elements).each(function () {
        width += top.$(this).outerWidth(true);
    });
    return width;
}


    </script>
</body>

</html>